<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <link rel="stylesheet" th:href="@{/lib/lui/css/layui.css}">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<div class="layui-container">
<div th:html="${school.id}"></div>
<div th:if="${edit}">
</div>
<form id="schoolForm" class="layui-form" action="edit" method="post">
    <input type="hidden" name="id" th:value="${school.id}"/>
    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-block">
            <div class="layui-upload">
                <button type="button" class="layui-btn" id="test1">选择图片</button>
                <div class="layui-upload-list">
                    <img src="/demo/img/3.png" class="layui-upload-img" id="demo1">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div th:if="${edit}" class="layui-input-block">
            <input  type="text" name="name" autocomplete="off" th:value="${school.name}" placeholder="请输入驾校名称" class="layui-input">
        </div>
        <div class="layui-form-mid" th:unless="${edit}" th:text="${school.name}"></div>
    </div>
    
     <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div th:if="${edit}" class="layui-input-block">
            <input  type="text" name="tel" autocomplete="off" th:value="${school.tel}" placeholder="请输入驾校电话" class="layui-input">
        </div>
        <div class="layui-form-mid" th:unless="${edit}" th:text="${school.tel}"></div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">地址</label>
        <div th:if="${edit}" class="layui-input-block">
            <input  type="text" name="address" lay-verify="title" autocomplete="off" th:value="${school.address}" placeholder="请输入地址" class="layui-input">
        </div>
        <div class="layui-form-mid" th:unless="${edit}" th:text="${school.address}"></div>
    </div>
    
    
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">介绍</label>
        <div th:if="${edit}" class="layui-input-block">
            <textarea class="layui-textarea" name="introduce" th:text="${school.introduce}">
            </textarea>
        </div>
        <div class="layui-form-mid" th:unless="${edit}" th:text="${school.introduce}"></div>
    </div>

</form>
</div>
<script th:src="@{/lib/jquery/jquery.js}"></script>
<script th:src="@{/lib/jquery/jquery.forms.js}"></script>
<script th:src="@{/lib/lui/layui.all.js}"></script>
<script type="text/javascript">
    $.fn.serializeObject = function()
    {
        var o = {};
        var a = this.serializeArray();
        $.each(a, function() {
            if (o[this.name] !== undefined) {
                if (!o[this.name].push) {
                    o[this.name] = [o[this.name]];
                }
                o[this.name].push(this.value || '');
            } else {
                o[this.name] = this.value || '';
            }
        });
        return o;
    };
</script>
<script type="text/javascript">
    layui.laydate.render({
        elem: '#date'
    });
    //layui.layedit.build('LAY_demo_editor');

    function doSave(fn){

        var data = $("#schoolForm").serializeObject();

        $.ajax("edit",{
            method:"post",
            contentType:"application/json; charset=utf-8",
            data:JSON.stringify(data),
            success:function(data) {
                if(data) {
                    parent.tips(1, "保存成功！");
                    fn.call();
                }else{
                    parent.tips(0, "保存信息失败！");
                }
            },
            error:function(e){
                parent.tips(0,e);
            }
        });

    }

</script>

</body>
</html>